﻿namespace Stratrgy
{
    internal class Hand
    {
        public static readonly int HANDVALE_GUU = 0;
        public static readonly int HANDVALE_CHO = 1;
        public static readonly int HANDVALE_PAA = 2;
        public static readonly Hand[] Hands = new Hand[]
        {
            new Hand(HANDVALE_GUU),
            new Hand(HANDVALE_CHO),
            new Hand(HANDVALE_PAA),
        };

        private static readonly string[] names = new string[]
        {
            "石头","剪刀","布"
        };

        private int handValue;
        private Hand(int handValue) 
        {
            this.handValue = handValue;
        }

        public static Hand GetHand(int handValue) 
        {
            return Hands[handValue];
        }

        public bool IsStrongerThan(Hand h) 
        {
            return this.Fight(h) == 1;
        }

        public bool IsWeakerThan(Hand h)
        {
            return this.Fight(h) == -1;
        }

        private int Fight(Hand h) 
        {
            if (this == h) 
            {
                return 0;
            }
            if ((this.handValue + 1) % 3 == h.handValue) 
            {
                return 1;
            }
            return -1;
        }

        public override string ToString() 
        {
            return names[handValue];
        }
    }
}
